/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Pruebas.Manolo;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMultiset;
import com.google.common.collect.Multiset;
import com.google.common.collect.Multisets;
import com.google.common.collect.Ordering;
import com.google.common.collect.SortedMultiset;
import com.google.common.collect.TreeMultiset;
import java.util.ArrayList;

import java.util.Comparator;
import java.util.List;
import java.util.Map.Entry;
import org.apache.commons.collections.bag.TreeBag;

public class pruebamierda{
    
//    public static <T> ImmutableList<Entry<T>> sortedByCount(Multiset<T> multiset) {
//        Ordering<Multiset.Entry<T>> countComp = new Ordering<Multiset.Entry<T>>() {
//            public int compare(Multiset.Entry<T> e1, Multiset.Entry<T> e2) {
//                return e2.getCount() - e1.getCount();
//            }
//        };
//        return countComp.immutableSortedCopy(multiset.entrySet());
//    }
    
    public static String mayor(TreeMultiset<String> set){
        String valor=null;
        int actual=0;
        Multiset.Entry<String> aux;
        
        for(String a : set.elementSet()){
            if( set.count(a)>actual)
                actual=set.count(a);
        } 
        
        return valor;
    }
    
    public static void main(String[] args){

        TreeMultiset<String> set = TreeMultiset.create();
        TreeBag a = new TreeBag();
        
        a.add("hola");
        a.add("adios");
        a.add("hola");
        a.add("miguel");
        a.add("hola");
        a.add("pepe");
        a.add("hola");
        System.out.println(a.first());
        System.out.println(a.last());

        
        //System.out.println(aux..lastEntry().getElement()+" "+aux.lastEntry().getCount());
        //System.out.println("esto "+set.descendingMultiset().size()+" "+set.descendingMultiset().firstEntry().getCount());
    }

}
